package my.study.java.lang.annotation.Annotation.examples.example1;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class MyUtil {

	/**
	 * 获取类和方法的注解
	 * @param args
	 */
	public static void main(String[] args) {
		pl("print the annotation of method");
		for (Method method : MyClass.class.getDeclaredMethods()) {
			for (Annotation annotation : method.getDeclaredAnnotations()) {
				MyAnnotation myAnnotation = (MyAnnotation) annotation;
				pl(myAnnotation.toString());
				pl(myAnnotation.id());
			}
		}
		pl("print the annotation of class");
		for (Annotation annotation : MyAnnotation.class.getDeclaredAnnotations()) {
			pl(annotation.toString());
		}

	}
	public static void pl(Object o) {
		System.out.println(o);
	}

}
